package com.higgins.eventtracking.server.dataModel;

import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;
import com.higgins.eventtracking.client.dto.HealthEventDTO;
import com.higgins.eventtracking.client.dto.InventoryDTO;
import com.higgins.eventtracking.server.DateUtility;

@PersistenceCapable
public class Inventory {
	@SuppressWarnings("unused")
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long id;
		
	@Persistent
	private String name;
	
	@Persistent
	private Date sellByDate;
	
	@Persistent
	private Boolean breakfast;
	
	@Persistent
	private Boolean main;
	
	@Persistent
	private Boolean snack;
	
	public Inventory()	{
		
	}
	public void setName(String name)	{
		this.name = name;
	}
	public String getName()	{
		return name;
	}
	public void setSellByDate(Date sellByDate)	{
		this.sellByDate = sellByDate;
	}
	public Date getSellByDate()	{
		return sellByDate;
	}
	public void setBreakfast(Boolean breakfast)	{
		this.breakfast = breakfast;
	}
	public Boolean getBreakfast()	{
		return breakfast;
	}
	public void setMain(Boolean main)	{
		this.main = main;
	}
	public Boolean getMain()	{
		return main;
	}
	public void setSnack(Boolean snack)	{
		this.snack = snack;
	}
	public Boolean getSnack()	{
		return snack;
	}
	public void update(InventoryDTO dto)	{
		setName(dto.getName());
		setSellByDate(DateUtility.convertStringToDate(dto.getSellByDateString()));
		setBreakfast(dto.getBreakfast());
		setMain(dto.getMain());
		setSnack(dto.getSnack());
	}
	public InventoryDTO toDTO()	{
		InventoryDTO dto = new InventoryDTO(id, name, sellByDate, 
				sellByDate.toString(), breakfast, main, snack);
		return dto;
	}

}
